<script>
	export default {
		onLaunch: function() {
			uni.showLoading({
				title: '加载中',
				mask: true
			});

			this.loadFont()
			uni.removeStorageSync('selectedIndex')
			uni.hideTabBar()
		},
		methods: {
			sendRequest(name, url) {
				return new Promise((resolve, reject) => {
					uni.loadFontFace({
						global: true,
						family: name,
						source: 'url(' + url + ')',
						fail: (e) => {
							reject(e)
						},
						success(e) {
							resolve(e)
						}
					})
				})
			},
			async loadFont() {
				try {
					await this.sendRequest('PingFang Bold',
						"https://s3-us-east-1.ossfiles.com/demoas/pingfangbold.woff2")
					await this.sendRequest('PingFang Regular',
						"https://s3-us-east-1.ossfiles.com/demoas/pingfangregular.woff2")
					await this.sendRequest('PingFang Medium', "https://s3-us-east-1.ossfiles.com/demoas/pdmf.woff2")
				} catch (err) {
					console.log(err);
				}
				uni.hideLoading()
			}
		}
	}
</script>

<style lang="less">
	/*每个页面公共css */

	page {
		width: 100vw;
		height: 100vh;
		font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
			'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
	}

	view,
	image,
	text {
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-row {
		display: flex;
		flex-direction: row;
	}

	.flex-col {
		display: flex;
		flex-direction: column;
	}

	.justify-start {
		justify-content: flex-start;
	}

	.justify-end {
		justify-content: flex-end;
	}

	.justify-center {
		justify-content: center;
	}

	.justify-between {
		justify-content: space-between;
	}

	.justify-around {
		justify-content: space-around;
	}

	.justify-evenly {
		justify-content: space-evenly;
	}

	.items-start {
		align-items: flex-start;
	}

	.items-end {
		align-items: flex-end;
	}

	.items-center {
		align-items: center;
	}

	.items-baseline {
		align-items: baseline;
	}

	.items-stretch {
		align-items: stretch;
	}

	.self-start {
		align-self: flex-start;
	}

	.self-end {
		align-self: flex-end;
	}

	.self-center {
		align-self: center;
	}

	.self-baseline {
		align-self: baseline;
	}

	.self-stretch {
		align-self: stretch;
	}

	.flex-1 {
		flex: 1 1 0%;
	}

	.flex-auto {
		flex: 1 1 auto;
	}

	.grow {
		flex-grow: 1;
	}

	.grow-0 {
		flex-grow: 0;
	}

	.shrink {
		flex-shrink: 1;
	}

	.shrink-0 {
		flex-shrink: 0;
	}

	.relative {
		position: relative;
	}
</style>